import React, { Component } from 'react';
import { Link, Redirect  } from 'react-router-dom';

class Index extends Component {
    constructor(props) {
        super(props);
        this.state = { 
            list: [
                { cid: 1, title: '这是第一' },
                { cid: 2, title: '这是第二' },
                { cid: 3, title: '这是第三' },
            ]
        }
        this.props.history.push("/home/");
    }
    render() { 
        return (
            <div>
                {/* <Redirect to="/home/"></Redirect> */}
                <h2>this is text</h2>
                <ul>
                    {
                        this.state.list.map((item)=>{
                            return (
                                <li key={item.cid}>
                                    <Link to={`/list/${item.cid}`}>
                                        {item.title}
                                    </Link>
                                </li>
                            )
                        })
                    }
                </ul>
            </div>
        );
    }
}

export default Index;